package com.xwj.auction.util;

import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;

/**
 * @author xwj
 * @date 2020/5/13
 */
public class DateUtil {
    /**
     * @param cur
     * @param hour
     * @return
     */
    public static Date plusHours(Date cur, Integer hour) {
        Calendar c = Calendar.getInstance();
        c.setTime(cur);
        c.add(Calendar.HOUR, hour);
        Date date = c.getTime();
        return date;
    }

    /**
     * @param cur
     * @param minutes
     * @return
     */
    public static Date plusMinutes(Date cur, Integer minutes) {
        Calendar c = Calendar.getInstance();
        c.setTime(cur);
        c.add(Calendar.MINUTE, minutes);
        Date date = c.getTime();
        return date;
    }

    public static Date minusMinutes(Date cur, Integer minutes) {
        Calendar c = Calendar.getInstance();
        c.setTime(cur);
        c.add(Calendar.MINUTE, -minutes);
        Date date = c.getTime();
        return date;
    }

    public static Date plusSeconds(Date cur, Integer seconds) {
        Calendar c = Calendar.getInstance();
        c.setTime(cur);
        c.add(Calendar.SECOND, seconds);
        Date date = c.getTime();
        return date;
    }
}
